Fix reserved expansion (e.g. "{+var}") when matching resources#1142
Merged
Fix reserved expansion (e.g. "{+var}") when matching resources#1142
Conversation
- Add more test cases
Contributor
There was a problem hiding this comment.
Pull request overview
This pull request fixes URI template parsing for reserved expansion ({+var}), label expansion ({.var}), and path-style parameters ({;var}). The bug was causing templates like samples://{dependency}/{+path} to fail when matching URIs with nested paths.
Changes:
- Fixed reserved expansion to properly match slashes and other reserved characters per RFC 6570
- Fixed label expansion to handle dot-prefixed values with correct separator logic
- Added support for path-style parameter expansion with semicolon-prefixed name=value pairs
- Added 757 lines of comprehensive tests covering all URI template operators and edge cases
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
src/ModelContextProtocol.Core/UriTemplate.cs |
Fixed operator handling in CreateParser switch statement, added AppendPathParameterExpression method, updated separator logic for multi-value expansions, and made UriTemplate class public |
tests/ModelContextProtocol.Tests/UriTemplateCreateParserTests.cs |
Added comprehensive test suite with 757 lines covering all RFC 6570 operators, edge cases, and regression tests for the fixed bugs |
tests/ModelContextProtocol.Tests/Configuration/McpServerResourceRoutingTests.cs |
Added integration test for the reserved expansion bug fix with nested path matching |
halter73
commented
Jan 13, 2026
stephentoub
reviewed
Jan 15, 2026
stephentoub
reviewed
Jan 21, 2026
tests/ModelContextProtocol.Tests/Configuration/McpServerResourceRoutingTests.cs
Show resolved
Hide resolved
stephentoub
previously approved these changes
Jan 21, 2026
stephentoub
approved these changes
Jan 27, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
@heaths